﻿<UserControl x:Class="DeltaGroup.WheelOfJeopardy.UI.Screens.Board"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Commands="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Commands" xmlns:Screens="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Screens" mc:Ignorable="d" 
              xmlns:converter="clr-namespace:DeltaGroup.WheelOfJeopardy.UI.Converters"
             d:DesignHeight="300" d:DesignWidth="300" HorizontalContentAlignment="Stretch" VerticalAlignment="Top" HorizontalAlignment="Center">
    <UserControl.CommandBindings>
        <CommandBinding Command="Commands:WoJCommands.SelectCategory" Executed="HandleCategorySelected"/>
    </UserControl.CommandBindings>
    <StackPanel  >
        <ItemsControl ItemsSource="{Binding Path=Categories, BindsDirectlyToSource=True}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate >
                <DataTemplate>
                    <StackPanel>
                        <Button Style="{StaticResource CategoryButton}" Width="80" Height="80" IsEnabled="{Binding Path=AllowSelection, BindsDirectlyToSource=True}" 
                                Command="Commands:WoJCommands.SelectCategory" CommandParameter="{Binding Category}" >
                            <Button.Content>
                                <TextBlock Text="{Binding Path=Category.Title}" TextWrapping="Wrap"/>
                            </Button.Content>
                        </Button>
                        <ItemsControl ItemsSource="{Binding Path=Category.Challenges, BindsDirectlyToSource=True, NotifyOnSourceUpdated=True}" >
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Screens:ChallengeBlock DataContext="{Binding}" DebugMode="{Binding Path=DebugMode, RelativeSource={RelativeSource AncestorType={x:Type UserControl}, Mode=FindAncestor}}" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </StackPanel>
</UserControl>
